<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<!-- 避免IE使用兼容模式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<meta name="renderer" content="webkit" />
<title>主页</title>
<link rel="icon" href="../favicon.ico" type="x-icon">
    
<link rel="stylesheet" type="text/css" href="../plugins/bootstrap/3.3.7/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="../plugins/jquery-easyui/1.8.6/themes/bootstrap/easyui.css" />
<link rel="stylesheet" type="text/css" href="../plugins/jquery-easyui/1.8.6/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="../plugins/bootstrap/3.3.7/css/bootstrap-theme.min.css" />
<link rel="stylesheet" type="text/css" href="../plugins/font-awesome/css/font-awesome.min.css" />
    
<link rel="stylesheet" type="text/css" href="../plugins/jquery-custom-scrollbar/jquery.mCustomScrollbar.min.css" />
    
    
<link rel="stylesheet" type="text/css" href="../css/zbootstrap.css" />
<link rel="stylesheet" type="text/css" href="../css/zeasyui.css" />
<link rel="stylesheet" type="text/css" href="../css/common.css" />
    
    
<script type="text/javascript" src="../plugins/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="../plugins/jquery-rstorage/1.3.2/jquery.rStorage.min.js"></script>
    
<script type="text/javascript" src="../plugins/jquery-easyui/1.8.6/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../plugins/jquery-custom-scrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
    
    
<script type="text/javascript" src="../js/zGlobal.js"></script>
<script type="text/javascript" src="../js/zApi.js"></script>
<script type="text/javascript" src="../js/zAlert.js"></script>
<script type="text/javascript" src="../js/zUtil.js"></script>
<script type="text/javascript" src="../js/zDict.js"></script>
<script type="text/javascript" src="../js/zDialog.js"></script>
    
</head>
<style>
#p-all .panel.layout-panel.layout-panel-north.panel-htop{
   box-shadow: rgba(60, 73, 61, 0.5) 0px 5px 4px;
}
</style>
<body  class="index noselect">

    <div id="p-all" class="easyui-layout" data-options="fit:true">
                
        <div id="p1" data-options="region:'west',split:false,border:false,width:200,hideExpandTool:true,collapsedSize:0,expandMode:'dock'" style="background:#3c454d;overflow: hidden;">
               <div id="menuscrool" style="overflow: hidden;height: 100%;padding-top: 5px;padding-bottom: 5px;">
               <div id="menu" style="overflow: hidden;"></div>
               </div>
        </div>
        <div id="p2" data-options="region:'center',split:false,border:false">
            <div id="tabs" style="">
            </div>
            <div id="tab-tools">
              <button href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true,iconCls:'fa fa-close fa-1'" title="关闭最后一个" onclick="tabPanelRemove()"></button>
              <button href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true,iconCls:'fa fa-arrows-alt fa-1'" title="浏览器全屏" onclick="App().handleFullScreen()"></button>
              <button href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true,iconCls:'fa fa-window-maximize fa-1'" title="隐藏菜单" onclick="menuToggle2()"></button>
            </div>
        </div>
         
        <div id="p3" data-options="region:'north',border:false,height:50,hideExpandTool:true,collapsedSize:0,expandMode:'dock'" >
            <div class="easyui-layout" data-options="fit:true" >
              <div data-options="region:'west',split:false,border:false" style="width:200px;">
                  <div style="height: 100%;text-align: center;overflow: hidden;">
                    <img id="logo" src="../image/zl-logo.png" class="logo"/>
                  </div>
              </div>
              <div data-options="region:'center',split:false,border:false" style="padding:5px;">

                    <div class="easyui-panel"
                        data-options="border:false,'align':'right'" style="padding: 5px;background: transparent;">
                        <a href="javascript:;" class="easyui-linkbutton" onclick="menuToggle()">
                           <i class="fa fa-outdent" aria-hidden="true"></i></a> 
                        <a href="#" class="easyui-linkbutton" data-options="plain:true" onclick="tabHome()">
                           <i class="fa fa-home" aria-hidden="true"></i> Home</a> 
                        <a href="#" class="easyui-menubutton" data-options="menu:'#helperMenu','align':'right',menuAlign: 'left'">
                           <i class="fa fa-question-circle" aria-hidden="true"></i> Help</a>
                    </div>
<!--                     <div id="userMenu" data-options="'noline':true" style="width: 150px;">
                        <div data-options="">注销登陆</div>
                    </div>-->
                    <div id="helperMenu" data-options="'noline':true,onClick:autocodeHelpFunc" style="width: 100px;">
                        <div id="mh-autocode" >代码生成步骤</div>
                    </div>

                </div>
            </div>
        </div>
        
    </div>
    
    <div id="tab-right-menu" class="" style="overflow: hidden; z-index: 100;">
                        <input id="tab-right-iframe" value="true" style="display:none" />
                        <input id="tab-right-selected" value="" style="display:none" />
                        <div id="tab-right-refresh" iconcls="fa fa-refresh" class="right-menu">刷新</div>
                        <div class="menu-sep"></div>
                        <div id="tab-right-closeself" iconcls="fa fa-close" class="right-menu">关闭</div>
                        <div id="tab-right-closeother" class="right-menu">关闭其他</div>
                        <div id="tab-right-closeall" class="right-menu">关闭全部</div>
                        <div id="tab-right-closeright" class="right-menu">关闭右侧标签</div>
                        <div id="tab-right-closeleft" class="right-menu">关闭左侧标签</div>
                        <div class="menu-sep"></div>
                        <div id="tab-right-newwindow" class="right-menu">独立窗口</div>
    </div>
    
    
    
<script type="text/javascript">
    var menuShowType = 0;
    var collapsedFlag = false;
    var toggleScreen = false;
    
    if (navigator.userAgent.indexOf("MSIE") > 0) {
        //IE
        document.onkeydown = function() {
            if (122 == event.keyCode) {
                if(toggleScreen){
                    zUtil.Toastr("warn","正在切换中...")
                    return false;
                }
                toggleScreen = true;
                App().handleFullScreen();
                toggleScreen = false;
                return false;
            }
        }
    } else {
        //非IE           
        window.onkeydown = function() {
            if (122 == event.keyCode) {
                if(toggleScreen){
                    zUtil.Toastr("warn","正在切换中...")
                    return false;
                }
                toggleScreen = true;
                App().handleFullScreen();
                toggleScreen = false;
                return false;
            }
        }
    }
        $(function(){
                        $('#menu').sidemenu({
                            width : 199,
//                             height: '100%',
                            border : false,
                            multiple : false,
                            data : zMenu['menu'],
                            onSelect : function(data) {
                                var sMenuId = $('#menu .tree-node-selected').attr('id');
                                data.sMenuId = sMenuId;
                                tabPanelAdd(data);
                            },
                        });
//                      TAB组件
                        $('#tabs').tabs({
                            tools : '#tab-tools',
                            fit : true,
                            border : false,
                            iframe: true,
                            top : 0,
                            onContextMenu: function (e, title, index) {
                                e.preventDefault();
                                $('#tabs').tabs('select',index);
                                if (index >= 0) {
                                    $('#tab-right-selected').val(title);
                                    $('#tab-right-menu').menu('show', {
                                        left: e.pageX,
                                        top: e.pageY
                                    });
                                }
                            },
                            onSelect : function(title, index) {
                               var tab = $('#tabs').tabs('getTab', index);
                               var sMenuId = $(tab).panel('options').sMenuId;
                               if($('#'+sMenuId).length>0 && !$('#'+sMenuId).hasClass('tree-node-selected')){
                                   $('#'+sMenuId).click();
                               }
                            },
                        });
                        
//                      TAB右键菜单
                        $('#tab-right-menu').menu({
                            height: 170,
                            width: 135,
                            onClick: function(item){
                                tabRightMenuOprate(item.id);
                            }
                        });
                        
                        tabHome();
                        //滚动条设置
                        $("#menuscrool").mCustomScrollbar();
 });
        
        function tabHome(){
            tabPanelAdd({href:"./home.html",title:"首页",id:"defaultHome",closable: false});
        };
        function tabOpen(menuId){
            if(menuId === "ZL_TABLE"){
                tabPanelAdd({href:"./autocode/table/tableIndex.html",title:"数据库表",id: menuId});
            }else  if(menuId === "ZL_KEYWORD"){
                tabPanelAdd({href:"./autocode/keyword/keywordIndex.html",title:"数据库关键字",id: menuId});
            }
            else  if(menuId === "ZL_FIELDMAPPING"){
                tabPanelAdd({href:"./autocode/fieldMapping/fieldMappingIndex.html",title:"字段映射",id: menuId});
            }
            else  if(menuId === "ZL_PROJECT"){
                tabPanelAdd({href:"./autocode/project/projectIndex.html",title:"项目信息",id: menuId});
            }
            else  if(menuId === "ZL_TEMPLATE"){
                tabPanelAdd({href:"./autocode/template/templateIndex.html",title:"模板信息",id: menuId});
            }
            else  if(menuId === "ZL_CONFIGGENERATE"){
                tabPanelAdd({href:"./autocode/cfgGenerate/cfgGenerateIndex.html",title:"代码生成配置",id: menuId});
            }
            else  if(menuId === "ZL_VALIDATION"){
                tabPanelAdd({href:"./autocode/validation/validationIndex.html",title:"校验规则",id: menuId});
            }
            else  if(menuId === "ZL_WEBCOMPONENT"){
                tabPanelAdd({href:"./autocode/webComponent/webComponentIndex.html",title:"前端组件",id: menuId});
            }
        };
        
          //增加TAB页
              function tabPanelAdd(options){
        	      if(options.url&&options.url.indexOf("http")!==-1){
        	          window.open(options.url,'_blank');
        	          return;
        	      }
                  var src, title, closable,sMenuId, menuId;
                  src = options.href;
                  title = options.title;
                  closable = options.closable;
                  sMenuId  = options.sMenuId;
                  menuId  = options.id;
                  var tabs = $('#tabs');
                  var alltabs = tabs.tabs('tabs');
                  var idx = null;
                  $.each(alltabs,function(i,n){
                       var popts = $(n).panel('options');
                       var index = $('#tabs').tabs('getTabIndex', $(n));
                       if((sMenuId && popts.sMenuId === sMenuId) || (menuId && popts.menuId === menuId)){
                           idx = index;
                           return false;
                       }
                  });
                  if (idx !=null  && tabs.tabs('exists',idx)) {
                      tabs.tabs('getTab', idx).panel('options').sMenuId = sMenuId;
                      tabs.tabs('select', idx);
                  } else {
                      var iframe = '<iframe src="' + src + '" frameborder="0" style="border:0;width:100%;height:100%;"></iframe>';
                      tabs.tabs('add',{
                          id: zUtil.uuid(),
                          title: title,
                          content: iframe,
                          closable: closable === false?false:true,
                          border: true,
                          sMenuId: sMenuId,
                          menuId: menuId,
//                        iconCls: '',
                      });
                  } 
              };
              //移除TAB页
              function tabPanelRemove(){
                  var tab = $('#tabs').tabs('getSelected');
                  if (tab){
                      var index = $('#tabs').tabs('getTabIndex', tab);
                      if(index>0){
                          $('#tabs').tabs('close', index);
                      }
                  }
              };
              //Tab菜单操作
              function tabRightMenuOprate(type) {
                  var allTabs = $('#tabs').tabs('tabs');
                  var allTabIds = [];
                  var allTabClosable = {};
                  $.each(allTabs, function(i, n){//全部放入保持索引一致
                      var opt = $(n).panel('options');
                      allTabIds.push(opt.id);
                      allTabClosable[opt.id] = opt.closable;
                  });
                  
                  var currentTab = $('#tabs').tabs('getSelected');
                  var curTabIndex = $('#tabs').tabs('getTabIndex',currentTab);
                  var currentTabOpts = currentTab.panel('options');// $.data(currentTab[0], 'panel').options;
                  var currentTabId = currentTabOpts.id;
                  switch (type) {
                      case "tab-right-refresh": //刷新
                          if ($('#tab-right-iframe').val()) {
                              var currentIframe = currentTab.find('iframe')[0];
                              currentIframe.contentWindow.location.href = currentIframe.src;
                          } else {
                              $(currentTab[0]).panel('refresh');
                          }
                          break;
                      case "tab-right-closeself": //关闭当前
                          if (allTabClosable[currentTabId]) {
                              $('#tabs').tabs("close", curTabIndex);
                          }
                          break;
                      case "tab-right-closeall": //全部关闭
                          $.each(allTabIds, function(i, n){
                              if (allTabClosable[n]) {
                                  $('#tabs').tabs('close', $('#tabs').tabs('getTabIndex',$('#'+n).panel()));
                              }
                          });
                          break;
                      case "tab-right-closeother": //除此之外全部关闭
                          $.each(allTabIds, function(i, n){
                              if (allTabClosable[n] && currentTabId != n) {
                                  $('#tabs').tabs('close', $('#tabs').tabs('getTabIndex',$('#'+n).panel()));
                              }
                          });
                          $('#tabs').tabs('scrollBy', 10);
                          $('#tabs').tabs('select', curTabIndex);
                          break;
                      case "tab-right-closeright": //当前侧面右边
                          $.each(allTabIds.reverse(), function(i, n){
                              if(currentTabId == n){
                                  return false;
                              }
                              if (allTabClosable[n]) {
                                  $('#tabs').tabs('close', $('#tabs').tabs('getTabIndex',$('#'+n).panel()));
                              }
                          });
                          $('#tabs').tabs('select', curTabIndex);
                          break;
                      case "tab-right-closeleft": //当前侧面左边
                          $.each(allTabIds, function(i, n){
                              if(currentTabId == n){
                                  return false;
                              }
                              if (allTabClosable[n]) {
                                  $('#tabs').tabs('close', $('#tabs').tabs('getTabIndex',$('#'+n).panel()));
                              }
                          });
                          $('#tabs').tabs('select', curTabIndex);
                          break;
                      case "tab-right-newwindow": //在新窗口打开
                          var refresh_iframe = currentTab.find('iframe')[0];
                          window.open(refresh_iframe.src);
                          break;
                      default : break;
                  }
               };
              //菜单模式切换
              function menuToggle(){
                  if(menuShowType === 2){
                      menuToggle2();
                      return false;
                  }
                  var opts = $('#menu').sidemenu('options');
                  menuShowType = opts.collapsed?0:1;
                  $('#menu').sidemenu(opts.collapsed ? 'expand' : 'collapse');
                  opts = $('#menu').sidemenu('options');
                  
                  $('#menu').sidemenu('resize', {
                      width: opts.collapsed ? 59 : 199
                  });
//                   $('#logo').toggleClass('logo-mini');
                  //取得原始属性
                  var wf1 = parseInt($('#p1').css('width'));
                  var wf2 = parseInt($('#p2').css('width'));
                  var lf2 = parseInt($('#p2').css('left'));
                  var diffWidth = opts.collapsed ? 60 : 200;
                  $('#p1').panel('resize',{
                      width: diffWidth
                  });
                  $('#p2').panel('resize',{
                      width: (wf1 + wf2)- diffWidth
                     ,left: diffWidth
                  });
              };
              //菜单模式切换
              function menuToggle2(){
                     var westp = $('#p-all').layout('panel','west').panel('options');
                     var northp = $('#p-all').layout('panel','north').panel('options');
                     var collapsed =  westp.collapsed || northp.collapsed;
                     if(collapsed){
                         if(northp.collapsed){
                             $('#p-all').children('.panel.layout-expand-north').click();
                         }
                         if(westp.collapsed){
                             $('#p-all').children('.panel.layout-expand-west').click();
                         }
                     }else{
                         if(!northp.collapsed){
                             $('#p-all').layout('collapse','north');
                         }
                         if(!westp.collapsed){
                             $('#p-all').layout('collapse','west');
                         }
                         $('#p-all').children('.panel.layout-expand').addClass("hidden");
                     }
              };
        //全屏处理
        var App = function () {
            var setFullScreen = function () {
                var docEle = document.documentElement;
                try{
                    if (docEle.requestFullscreen) {
                        //W3C
                        docEle.requestFullscreen();
                    } else if (docEle.mozRequestFullScreen) {
                        //FireFox
                        docEle.mozRequestFullScreen();
                    } else if (docEle.webkitRequestFullScreen) {
                        //Chrome等
                        docEle.webkitRequestFullScreen();
                    } else if (docEle.msRequestFullscreen) {
                        //IE11
                        docEle.msRequestFullscreen();
                    } else {
                        $.messager.alert('温馨提示', '该浏览器不支持全屏', 'messager-warning');
                    }
                }catch(b){
                }
            };

            //退出全屏 判断浏览器种类
            var exitFullScreen = function () {
                // 判断各种浏览器，找到正确的方法
                var exitMethod = document.exitFullscreen || //W3C
                    document.mozCancelFullScreen ||    //Chrome等
                    document.webkitExitFullscreen || //FireFox
                    document.msExitFullscreen; //IE11
                
                try{
                    if (exitMethod) {
                        exitMethod.call(document);
                    }
                    else if (typeof window.ActiveXObject !== "undefined") {//for Internet Explorer
                        var wscript = new ActiveXObject("WScript.Shell");
                        if (wscript !== null) {
                            wscript.SendKeys("{F11}");
                        }
                    }
                }catch(b){
                }
            };

            var checkIsFullScreen = function(){
                return (document.body.scrollHeight == window.screen.height 
                      && document.body.scrollWidth == window.screen.width);
            };
            
            return {
                init: function () {

                },
                handleFullScreen: function () {
                    if (checkIsFullScreen()) {
                        exitFullScreen();
                    } else {
                        setFullScreen();
                    }
                }
            };
        };
        
        function autocodeHelpFunc(item){
            if(item==='mh-autocode' || item['id']==='mh-autocode'){
                zUtil.dialogInit2("#autocodeHelpDlg",{
                    title: item.text,
                    width: 800,
                    height: 600,
                    collapsible: true,
                    modal: false,
                    href:"./autocode/helperAutocode.html"
                  }
                ,[1]
                ,[function(){
                    zUtil.dialogClose("#autocodeHelpDlg");
                }]);
                zUtil.dialogOpen("#autocodeHelpDlg");
            }
        }
            
//         autocodeHelpFunc({text:"代码生成"});
        </script>

</body>
</html>